﻿@{
    ViewBag.Title = "Form";
    Layout = "~/Views/Shared/_Form.cshtml";
}
<script>    
    var RouteCode = getQueryParam("RouteCode");
    console.log('子页面等级', RouteCode)
    $(document).ready(function () {
        // 获取 keyValue
        var keyValue = getQueryParam("keyValue");
        const rawCheckPort = getQueryParam("rawCheckPort");
        const rawDjProcedureCompany = getQueryParam("rawDjProcedureCompany");
        console.log('子页面BridgeCode', keyValue)
        console.log('子页面rawCheckPort', rawCheckPort)
        console.log('子页面rawDjProcedureCompany', rawDjProcedureCompany)
        if (keyValue) {
            $("#BridgecodeDisplay").text(keyValue);
            $("#F_CreatorTime").val(rawCheckPort);
            $("#F_StartIP").val(rawDjProcedureCompany);
        } else {
            console.error('keyValue 参数未找到！');
            $("#BridgecodeDisplay").text("参数未找到！");
        }
    });
    function getQueryParam(name) {
        const urlParams = new URLSearchParams(window.location.search);
        return urlParams.get(name);
    }
    var keyValue = getQueryParam("keyValue");
    // 提交表单处理
    function submitForm() {
        const formData = new FormData();
        const fileInput = document.getElementById('fileInput');
        console.log('fileInput',fileInput);
        if (fileInput.files.length > 0) {
            formData.append("Djport", fileInput.files[0]);
        } else {
            alert("请选择定检报告");
            return;
        }

        // 添加其他参数
        formData.append("queryJson", $("#F_EvaluationDate").val());
        formData.append("bridgeCode", keyValue);
        console.log('keyValue', keyValue);
        formData.append("RouteCode", $("#F_Type").val());
        formData.append("DJprocedure", $("#F_StartIP").val());
        $.ajax({
            url: "/SystemSecurity/BridgeMange/UpdateBrigdeData11",
            type: "POST",
            data: formData,
            processData: false,
            contentType: false,
            success: function (res) {
                alert("上传成功");
                parent.layer.close(parent.layer.getFrameIndex(window.name));
                 parent.layer.closeAll();
            }
        });
    }
    var keyValue = $.request("keyValue");
    $(function () {
        $("#F_Type").bindSelect()
        $.ajax({
            url: "/SystemSecurity/FilterIP/GetFormJson",
            data: { keyValue: keyValue },
            dataType: "json",
            async: false,
            type: "GET",
            success: function (data) {
                $("#form1").formSerialize(data);
            }
        });
    });

</script>

<form id="form1">
    <div style="margin-bottom: 0px; border-radius: 0px;" class="alert alert-warning alert-dismissable">
        <strong>注意：</strong>&nbsp;请准确输入定检承担单位等字段
    </div>
    <div style="padding-top: 20px; margin-right: 20px;">
        <div class="gridPanel">
            <table id="gridList"></table>
        </div>
        <table class="form">
            <tr>
                <th class="formTitle">桥梁代码</th>
                <td class="formValue">
                    <span id="BridgecodeDisplay"></span>
                    <!-- 或使用 <input type="text" id="BridgecodeDisplay" readonly class="form-control"> -->
                </td>
            </tr>
            <tr>
                <th class="formTitle">定检承担单位</th>
                <td class="formValue">
                    <input id="F_StartIP" name="F_StartIP" type="text" class="form-control" />
                </td>
            </tr>
            <tr>
                <th class="formTitle">评定等级</th>
                <td class="formValue">
                    <select id="F_Type" name="F_Type" class="form-control">
                        <option value="">==请选择==</option>
                        <option value="level1">level1</option>
                        <option value="level2">level2</option>
                        <option value="level3">level3</option>
                        <option value="level4">level4</option>
                        <option value="level5">level5</option>
                    </select>
                </td>
            </tr>
            <tr>
                <th class="formTitle" style="height: 35px;">选项</th>
                <td class="formValue" style="padding-top: 1px;">
                    <div class="ckbox">
                        <input id="F_EnabledMark" name="F_EnabledMark" type="checkbox" checked="checked"><label for="F_EnabledMark">有效</label>
                    </div>
                </td>
            </tr>
            <tr>
                <th class="formTitle" valign="top" style="padding-top: 11px;">
                    检查日期
                </th>
                <td class="formValue">
                    <input type="date"
                           id="F_CheckDate"
                           name="F_CheckDate"
                           class="form-control"
                           value=""
                           style="height: 34px; line-height: 1.42857143;">
                </td>
            </tr>
            <tr>
                <th class="formTitle">评定日期</th>
                <td class="formValue">
                    <input type="date"
                           id="F_EvaluationDate"
                           name="F_EvaluationDate"
                           class="form-control"
                           style="height: 34px; line-height: 1.42857143;">
                </td>
            </tr>


            <tr>
                <th class="formTitle">定检报告</th>
                <td>
                        <input type="file" name="file" id="fileInput">
                </td>
            </tr>
        </table>
        <div style="margin-top: 30px; text-align: center; border-top: 1px solid #eee; padding-top: 20px;">
            <button type="submit"
                    class="btn btn-primary btn-lg"
                    style="min-width: 150px;"
                    onclick="return submitForm()">
                <i class="fa fa-save"></i> 提交
            </button>
        </div>
    </div>
</form>
